<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/jquery-3.5.1.min.js"></script>
    <script src="/main.js"></script>
</head>
<body>
    <button id="btn_test_urlpost">点击测试提交urlencode格式数据</button>
    <button id="btn_test_jsonpost">点击测试提交json格式数据</button>
    <div></div>

<script>
    let smm=$.moon();
    let test_url="http://symlink.dk/code/php/submit/";//这个网址只支持 application/x-www-form-urlencoded 编码
    $("#btn_test_urlpost").click(function () {
        smm.header("Content-type: application/x-www-form-urlencoded")
            .post(test_url,"user=1246&passwd=456789",function (data) {
                $("div").html(data);
            })
    })
    smm.get("https://fanyi.baidu.com/");
    $("#btn_test_jsonpost").click(function () {
        let data = JSON.stringify({
            from: "zh",
            to: "en",
            query: "这是post 提交的结果",
            transtype: "realtime",
            simple_means_flag: 3,
            sign: 539577.841864,
            token: "f10fb7a7d2cf7ab7bfb647bba7a6eac8",
            domain: "common"
        });

        smm.header("Content-type: application/json")
        .post("https://fanyi.baidu.com/v2transapi?from=zh&to=en",data,function (data,rawdata) {
            $("div").text(eval("'"+rawdata.data+"'"));//eval仅仅只是处理一下\u编码的显示
        })
    })
</script>
</body>
</html>